<?php $this->headLink()->appendStylesheet($this->css('flora/flora.all.css'))?>
<?php $this->headScript()
	->appendFile($this->js('jquery/ui/jquery.ui.dialog.js'))
	->appendFile($this->js('jquery/ui/jquery.ui.resizable.js'))
	->appendFile($this->js('jquery/ui/jquery.ui.draggable.js'))
	->appendFile($this->js('jquery/plugins/form/jquery.form.js'))
	->appendFile($this->js('jquery/plugins/jquery.bgiframe.js'))
	->captureStart()?>
	var year_name = <?php echo $this->year_name ?>;
	var writeWin = null;

		function writeLeft(pic) {
		writeWin = window.open('','aWin','scrollbars,resizable,top=0,left=0,height=480,width=640');

		var ePen = "<html><head><title>圖檔展示</title></head> ";
		ePen +=  "<body text='#666666' bgcolor='#ffffff'> ";
		ePen +=  '<center><img src="<?php echo $this->baseScript ?>/index/getimg/'+pic+'"></center></body></html>';

		var wd = writeWin.document;

		wd.open();
		wd.write(ePen);
		wd.close();
		}

		function blowOut() {
		if (writeWin != null && writeWin.open) writeWin.close();
		}
		window.onfocus=blowOut;

 $(document).ready(function(){
 	$("#set_year").click(function(){
 		var id=$("#length_id").val();
 		var ss='';
 		jQuery.each(year_name[id],function(i,val){
 			ss += i+'. <input type="text" name="year_name['+i+']" value="'+val+'" /> <br />' ;
 		});
 		$("#con").html(ss);
 		$("#dialog").css('display','inline');
		$("#dialog").attr('title','設定年段名稱');
		$("#dialog").dialog({
 			modal: true,
	    	height: 350
		}).bgiframe();
 	});

 	var options = {
          success:       function(data){
        	$("#dialog").dialog("close");
        	var id=$("#length_id").val();
        	//alert(data['tid']);
        	eval('var z='+data);

        	year_name[id]= z;
        	//alert(year_name[id][1]);

        }
    };

    // bind form using 'ajaxForm'
    $('#setForm').ajaxForm(options);

 });

<?php $this->headScript()->captureEnd() ?>



<div id="dialog" class="flora" title="上傳簽名檔" style="display:none;">
<div  style="padding:10px">
<form action="<?php echo $this->baseScript ?>/setyear" id="setForm" method="post">
<div id="con"></div>

<br />
<input type="submit" id="setBtn" class="like_button" value="設定年級" />
</form>
</div>
</div>
<form method='post' action="<?php echo $this->baseScript?>/edit" id="myform"  encType='multipart/form-data' >
<div><input type='submit' name='act' value='儲存學校資料'></div>
<div class='main_body'>
	<table border='1'>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>教育機關代碼</td>

		<td><input type='text' size='6' maxlength='6' name='school[id]' value='<?php echo $this->data->getId() ?>'>
		<a href='http://sfs.wpes.tcc.edu.tw/school/qid.php' target=new>查詢</a></td>
		<td class='title_sbody1'>屬性</td>
		<td>
		<select name='school[attribute]'>
		<?php foreach($this->school->getAttributeArr() as $val) :?>
		<option value="<?php echo $val ?>"  <?php if($val==$this->data->attribute): ?>selected<?php endif ?> ><?php echo $val ?></option>
		<?php endforeach ?>
		</select>
		</td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學制</td>
		<td colspan='3'>
		<select id="length_id" name="school[length]">
		<?php foreach($this->school->getAttrArr() as $id=>$val): ?>
		<option value="<?php echo $id?>" <?php if($this->data->length==$id): ?> selected<?php endif ?>><?php echo $val ?>(<?php echo $id ?>)</option>
		<?php endforeach; ?>
		</select>
		<span id="set_year" class="like_button">設定年段名稱</span>
		</td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>政府機關代碼</td>
		<td colspan='3'><input type='text' size='12' maxlength="20" name="school[governmental_id]" value="<?php echo $this->data->getGovernmental_id()?>"></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>商業統一編號</td>
		<td colspan='3'><input type='text' size='12' maxlength="20" name="school[commercial_id]" value="<?php echo $this->data->getCommercial_id()?>"></td>
	</tr>

	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>中文名稱（全銜）</td>
		<td colspan='3'><input type='text' size='40' maxlength='40' name='school[name]' value='<?php echo $this->data->getName() ?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>中文名稱（簡稱）</td>

		<td colspan='3'><input type='text' size='40' maxlength='40' name='school[name_short]' value='<?php echo $this->data->name_short?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>中文名稱（短稱）</td>
		<td colspan='3'><input type='text' size='40' maxlength='40' name='school[name_brief]' value='<?php echo $this->data->name_brief?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>英文名稱</td>

		<td colspan='3'><input type='text' size='40' maxlength='60' name='school[english_name]' value='<?php echo $this->data->english_name?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>縣市別</td>
		<td>
		<select name='school[county]'>
		<option value=''>
		<?php foreach($this->school->getCountyArr() as $val) :?>
		<option value="<?php echo $val ?>" <?php if($val == $this->data->county): ?>selected<?php endif ?> ><?php echo $val ?></option>
		<?php endforeach ?>
		</select>
		</td>

		<td  class='title_sbody1' >成立日期（西元）</td>
		<td><input type='text' size='10' maxlength='10' name='school[form_date]' value='<?php echo $this->data->form_date?>'>（例：1918-7-1）</td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>運作狀態註記</td>
		<td>
		<select name='school[mark]'>
		<option value=''>
		<?php foreach($this->school->getMarkArr() as $val): ?>
		<option value="<?php echo $val ?>"  <?php if($val==$this->data->mark): ?>selected<?php endif ?>><?php echo $val ?></option>
		<?php endforeach; ?>
		</select>
		</td>
		<td  class='title_sbody1'>級別</td>
		<td>
		<select name='school[area]'>
		<option value=''>
		<?php foreach($this->school->getAreaArr() as $val): ?>
		<option value="<?php echo $val ?>" <?php if($val == $this->data->area): ?>selected<?php endif ?>><?php echo $val ?></option>
		<?php endforeach; ?>
		</select>
		</td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>山地識別</td>
		<td>
		<select name='school[montane]'>
		<option value=''>
		<?php foreach($this->school->getYesNoArr() as  $val): ?>
		<option value="<?php echo $val ?>" <?php if($val==$this->data->montane): ?>selected<?php endif ?>><?php echo $val ?></option>
		<?php endforeach; ?>
		</select>
		</td>
		<td  class='title_sbody1'>校地總面積</td>
		<td><input type='text' size='10' maxlength='10' name='school[plottage]' value='<?php echo $this->data->plottage?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>校地總延面積</td>

		<td><input type='text' size='10' maxlength='10' name='school[plottage_expand]' value='<?php echo $this->data->plottage_expand?>'></td>
		<td  class='title_sbody1'>建坪面積</td>
		<td><input type='text' size='10' maxlength='10' name='school[floor_space]' value='<?php echo $this->data->floor_space?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>資本門支出</td>
		<td><input type='text' size='10' maxlength='10' name='school[expense_capital]' value='<?php echo $this->data->expense_capital?>'> 元</td>

		<td  class='title_sbody1'>經常門支出</td>
		<td><input type='text' size='10' maxlength='10' name='school[expense_ordinary]' value='<?php echo $this->data->expense_ordinary?>'> 元</td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>鄉鎮市區別</td>
		<td><input type='text' size='10' maxlength='10' name='school[township]' value='<?php echo $this->data->township?>'></td>
		<td  class='title_sbody1'>郵遞區號</td>

		<td><input type='text' size='5' maxlength='5' name='school[zip_code]' value='<?php echo $this->data->zip_code?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學校地址</td>
		<td colspan='3'><input type='text' size='60' maxlength='60' name='school[address]' value='<?php echo $this->data->address?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學校電話</td>

		<td><input type='text' size='20' maxlength='20' name='school[phone]' value='<?php echo $this->data->phone?>'></td>
		<td  class='title_sbody1'>學校傳真</td>
		<td><input type='text' size='20' maxlength='20' name='school[fax]' value='<?php echo $this->data->fax?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學校行政區</td>
		<td><input type='text' size='20' maxlength='20' name='school[district]' value='<?php echo $this->data->district?>'></td>
		<td  class='title_sbody1'>規模類型</td>

		<td><input type='text' size='6' maxlength='6' name='school[scale]' value='<?php echo $this->data->scale?>'></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學校網址</td>
		<td>http:// <input type='text' size='20' maxlength='50' name='school[website]' value='<?php echo $this->data->website?>'></td>
		<td  class='title_sbody1'>電子郵件</td>
		<td><input type='text' size='20' maxlength='60' name='school[email]' value='<?php echo $this->data->email?>'></td>

	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學校平面圖</td>
		<td colspan='3'><a href="javascript:writeLeft('sch_area_img')">平面圖</a>&nbsp;&nbsp;<input type='file'  name='sch_area_img' ></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>學校交通圖</td>

		<td colspan='3'><a href="javascript:writeLeft('sch_traffic_img')">交通圖</a>&nbsp;&nbsp;<input type='file'   name='sch_traffic_img' ></td>
	</tr>
	<tr bgcolor='#FFFFFF'>
		<td class='title_sbody1'>首頁標題圖</td>
		<td colspan='3'><a href="javascript:writeLeft('logo_picture')">首頁標題圖</a>&nbsp;&nbsp;<input type='file'  name='logo_picture' ></td>
	</tr>

	</table>
	</div>
	<div><input type='submit' name='act' value='儲存學校資料'></div>
	</form>

